package cn.edu.cqupt.cxcy.dto;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.edu.cqupt.cxcy.dao.TeacDao;
import cn.edu.cqupt.cxcy.model.Investor;
import cn.edu.cqupt.cxcy.model.Project;
import cn.edu.cqupt.cxcy.model.Projectinvest;
import cn.edu.cqupt.cxcy.model.Team;
import cn.edu.cqupt.cxcy.model.Tutor;
import cn.edu.cqupt.cxcy.util.Conn;
import cn.edu.cqupt.cxcy.util.SqlHelper;

public class TeacImpl implements TeacDao{

	@Override
	public ArrayList<Map<String, Object>> ProjectShowToTeacher(
			int project_status) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ArrayList<Map<String, Object>> EceptInfoOfProject(int ProjectId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean checkInfoOfProject(int ProjectId) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public ArrayList<Project> AllOfProject() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Team> ShowOfTeam(int te_id, int status,int team_status) {
		List<Team> show=new ArrayList<Team>(); 
		String sql = "";
		if(status == 1) {
			sql="select te_id from teamtutor where tu_id ="+te_id+" and tt_teamcheck=1";
		} else {
			sql="select te_id from teamtutor where tu_id ="+te_id+" and tt_tutorcheck ="+team_status+" and tt_teamcheck=2";
		}
		int id=0;
		try
		{
			ResultSet rs=SqlHelper.executeQuery(sql, null);

			while(rs.next())
			{
				id=rs.getInt("te_id");
				rs.close();

				sql="select * from team where te_id ="+id+"";
				rs=SqlHelper.executeQuery(sql,null);
				Team one=new Team();
				while(rs.next())
				{
					one.setTe_id(rs.getInt("te_id"));
					one.setTe_check(rs.getString("te_check"));
					one.setTe_ctime(rs.getDate("Te_ctime"));
					one.setTe_explain(rs.getString("te_explain"));
					one.setTe_logo(rs.getString("te_logo"));
					one.setTe_name(rs.getString("te_name"));
					show.add(one);
				}

			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			SqlHelper.close(SqlHelper.getRs(), SqlHelper.getPs(), SqlHelper.getConn());
		}
		return show;
	}

public Team showinfoofteam (String team_id)
{
	Team one=null;
	String sql="select * from team where te_id ="+team_id+"";
	try{
	ResultSet rs=SqlHelper.executeQuery(sql,null);
	
	while(rs.next())
	{
		one.setTe_id(rs.getInt("te_id"));
		one.setTe_check(rs.getString("te_check"));
		one.setTe_ctime(rs.getDate("Te_ctime"));
		one.setTe_explain(rs.getString("te_explain"));
		one.setTe_logo(rs.getString("te_logo"));
		one.setTe_name(rs.getString("te_name"));
	}
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	return one;
	}
}
